{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<div style=\"color:#777777;background-color:#ffffff;font-size:12px;text-align:right;\">\n",
    "\tprepared by Abuzer Yakaryilmaz (QuSoft@Riga) | November 07, 2018\n",
    "</div>\n",
    "<table><tr><td><i> I have some macros here. If there is a problem with displaying mathematical formulas, please run me to load these macros.</i></td></td></table>\n",
    "$ \\newcommand{\\bra}[1]{\\langle #1|} $\n",
    "$ \\newcommand{\\ket}[1]{|#1\\rangle} $\n",
    "$ \\newcommand{\\braket}[2]{\\langle #1|#2\\rangle} $\n",
    "$ \\newcommand{\\inner}[2]{\\langle #1,#2\\rangle} $\n",
    "$ \\newcommand{\\biginner}[2]{\\left\\langle #1,#2\\right\\rangle} $\n",
    "$ \\newcommand{\\mymatrix}[2]{\\left( \\begin{array}{#1} #2\\end{array} \\right)} $\n",
    "$ \\newcommand{\\myvector}[1]{\\mymatrix{c}{#1}} $\n",
    "$ \\newcommand{\\myrvector}[1]{\\mymatrix{r}{#1}} $\n",
    "$ \\newcommand{\\mypar}[1]{\\left( #1 \\right)} $\n",
    "$ \\newcommand{\\mybigpar}[1]{ \\Big( #1 \\Big)} $\n",
    "$ \\newcommand{\\sqrttwo}{\\frac{1}{\\sqrt{2}}} $\n",
    "$ \\newcommand{\\dsqrttwo}{\\dfrac{1}{\\sqrt{2}}} $\n",
    "$ \\newcommand{\\onehalf}{\\frac{1}{2}} $\n",
    "$ \\newcommand{\\donehalf}{\\dfrac{1}{2}} $\n",
    "$ \\newcommand{\\hadamard}{ \\mymatrix{rr}{ \\sqrttwo & \\sqrttwo \\\\ \\sqrttwo & -\\sqrttwo }} $\n",
    "$ \\newcommand{\\vzero}{\\myvector{1\\\\0}} $\n",
    "$ \\newcommand{\\vone}{\\myvector{0\\\\1}} $\n",
    "$ \\newcommand{\\vhadamardzero}{\\myvector{ \\sqrttwo \\\\  \\sqrttwo } } $\n",
    "$ \\newcommand{\\vhadamardone}{ \\myrvector{ \\sqrttwo \\\\ -\\sqrttwo } } $\n",
    "$ \\newcommand{\\myarray}[2]{ \\begin{array}{#1}#2\\end{array}} $\n",
    "$ \\newcommand{\\X}{ \\mymatrix{cc}{0 & 1 \\\\ 1 & 0}  } $\n",
    "$ \\newcommand{\\Z}{ \\mymatrix{rr}{1 & 0 \\\\ 0 & -1}  } $\n",
    "$ \\newcommand{\\Htwo}{ \\mymatrix{rrrr}{ \\frac{1}{2} & \\frac{1}{2} & \\frac{1}{2} & \\frac{1}{2} \\\\ \\frac{1}{2} & -\\frac{1}{2} & \\frac{1}{2} & -\\frac{1}{2} \\\\ \\frac{1}{2} & \\frac{1}{2} & -\\frac{1}{2} & -\\frac{1}{2} \\\\ \\frac{1}{2} & -\\frac{1}{2} & -\\frac{1}{2} & \\frac{1}{2} } } $\n",
    "$ \\newcommand{\\CNOT}{ \\mymatrix{cccc}{1 & 0 & 0 & 0 \\\\ 0 & 1 & 0 & 0 \\\\ 0 & 0 & 0 & 1 \\\\ 0 & 0 & 1 & 0} } $\n",
    "$ \\newcommand{\\norm}[1]{ \\left\\lVert #1 \\right\\rVert } $"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<h2>Two Qubits</h2>\n",
    "\n",
    "When we have a quantum system with two qubits, then we can represent its states as\n",
    "\n",
    "$ \\ket{00}, \\ket{01}, \\ket{10}, \\ket{11} $.\n",
    "\n",
    "The state $ \\ket{ab} $ means that \n",
    "<ul>\n",
    "    <li>the first qubit is in state $ \\ket{a} $ and </li>\n",
    "    <li> the second qubit is in state $ \\ket{b} $, </li>\n",
    "</ul>\n",
    "where $ a,b \\in \\{0,1\\} $."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<h3> Vector representation: </h3>\n",
    "    \n",
    "The vector representations of $ \\ket{00}, \\ket{01}, \\ket{10}, \\ket{11} $ are as follows:\n",
    "\n",
    "$$\n",
    "    \\ket{00} = \\myvector{1 \\\\ 0 \\\\ 0 \\\\ 0},\n",
    "    ~~~~~~\n",
    "    \\ket{01} = \\myvector{0 \\\\ 1 \\\\ 0 \\\\ 0},\n",
    "    ~~~~~~\n",
    "    \\ket{10} = \\myvector{0 \\\\ 0 \\\\ 1 \\\\ 0},\n",
    "    ~~~ \\mbox{ and }  ~~~\n",
    "    \\ket{11} = \\myvector{0 \\\\ 0 \\\\ 0 \\\\ 1}.\n",
    "$$\n",
    "\n",
    "\n",
    "\n",
    "The relation between state $ \\ket{ab} $ and the states  $ \\ket{a} $ and $ \\ket{b} $ is very simple:\n",
    "\n",
    "$ \\ket{ab} = \\ket{a} \\otimes \\ket{b} $. \n",
    "\n",
    "It is also shortly written as $ \\ket{ab} = \\ket{a} \\ket{b}  $ by omitting the tensor product operator."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Let's quickly verify each vector representation. \n",
    "\n",
    "Remember that $ \\ket{0} = \\myvector{1 \\\\ 0} $ and $ \\ket{1} = \\myvector{0 \\\\ 1} $.\n",
    "\n",
    "$$\n",
    "    \\ket{00} =  \\ket{0} \\otimes \\ket{0} = \\vzero \\otimes \\vzero =  \\myvector{1 \\\\ 0 \\\\ 0 \\\\ 0}.\n",
    "$$\n",
    "\n",
    "$$\n",
    "    \\ket{01} =  \\ket{0} \\otimes \\ket{1} = \\vzero \\otimes \\vone =  \\myvector{0 \\\\ 1 \\\\ 0 \\\\ 0}.\n",
    "$$\n",
    "\n",
    "$$\n",
    "    \\ket{10} =  \\ket{1} \\otimes \\ket{0} = \\vone \\otimes \\vzero =  \\myvector{0 \\\\ 0 \\\\ 1 \\\\ 0}.\n",
    "$$\n",
    "\n",
    "$$\n",
    "    \\ket{11} =  \\ket{1} \\otimes \\ket{1} = \\vone \\otimes \\vone =  \\myvector{0 \\\\ 0 \\\\ 0 \\\\ 1}.\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<h3>Applying Hadamards to both qubits</h3>\n",
    "\n",
    "Applying h-gate to the first and second qubits is the same as applying the following single operator on both qubits:\n",
    "\n",
    "$$\n",
    "   H^{\\otimes 2} = H \\otimes H = \\hadamard \\otimes \\hadamard = \\Htwo .\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<h4> Case 1: Let's find $ H^{\\otimes 2} \\ket{00} $ (in three different ways) </h4>\n",
    "<ul>\n",
    "    <li> Direct matrix-vector multiplication:\n",
    "        $$\n",
    "            H^{\\otimes 2} \\ket{00} \n",
    "            = \\Htwo \\myvector{1 \\\\ 0 \\\\ 0 \\\\ 0} \n",
    "            = \\myvector{ \\frac{1}{2} \\\\ \\frac{1}{2} \\\\ \\frac{1}{2} \\\\ \\frac{1}{2} } .\n",
    "        $$ </li> \n",
    "    <li> We calculate the quantum state of each state, and then find the quantum state of the composite system.\n",
    "        $$\n",
    "            H\\ket{0} \\otimes H \\ket{0} \n",
    "            = \\vhadamardzero \\otimes \\vhadamardzero \n",
    "            = \\myvector{ \\frac{1}{2} \\\\ \\frac{1}{2} \\\\ \\frac{1}{2} \\\\ \\frac{1}{2} }.\n",
    "        $$ </li>\n",
    "    <li> We make calculations with $ \\ket{0} $ and $ \\ket{1} $.\n",
    "        $$\n",
    "            H \\ket{0} \\otimes H \\ket{0} \n",
    "            = \\mypar{ \\frac{1}{\\sqrt{2}} \\ket{0} + \\frac{1}{\\sqrt{2}} \\ket{1} } \n",
    "                \\otimes \\mypar{ \\frac{1}{\\sqrt{2}} \\ket{0} + \\frac{1}{\\sqrt{2}} \\ket{1} }\n",
    "            = \\frac{1}{2} \\ket{00} + \\frac{1}{2} \\ket{01} + \\frac{1}{2} \\ket{10} + \\frac{1}{2} \\ket{11} \n",
    "            = \\myvector{ \\frac{1}{2} \\\\ \\frac{1}{2} \\\\ \\frac{1}{2} \\\\ \\frac{1}{2} }.\n",
    "        $$\n",
    "</ul>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<h4> Case 2: Let's find $ H^{\\otimes 2} \\ket{01} $ (in three different ways) </h4>\n",
    "<ul>\n",
    "    <li> Direct matrix-vector multiplication:\n",
    "        $$\n",
    "            H^{\\otimes 2} \\ket{01} \n",
    "            = \\Htwo \\myvector{0 \\\\ 1 \\\\ 0 \\\\ 0} \n",
    "            = \\myrvector{ \\frac{1}{2} \\\\ - \\frac{1}{2} \\\\ \\frac{1}{2} \\\\ - \\frac{1}{2} } .\n",
    "        $$ </li> \n",
    "    <li> We calculate the quantum state of each state, and then find the quantum state of the composite system.\n",
    "        $$\n",
    "            H\\ket{0} \\otimes H \\ket{1} \n",
    "            = \\vhadamardzero \\otimes \\vhadamardone \n",
    "            = \\myrvector{ \\frac{1}{2} \\\\ - \\frac{1}{2} \\\\ \\frac{1}{2} \\\\ - \\frac{1}{2} }.\n",
    "        $$ </li>\n",
    "    <li> We make calculations with $ \\ket{0} $ and $ \\ket{1} $.\n",
    "        $$\n",
    "            H \\ket{0} \\otimes H \\ket{1} \n",
    "            = \\mypar{ \\frac{1}{\\sqrt{2}} \\ket{0} + \\frac{1}{\\sqrt{2}} \\ket{1} } \n",
    "                \\otimes \\mypar{ \\frac{1}{\\sqrt{2}} \\ket{0} - \\frac{1}{\\sqrt{2}} \\ket{1} }\n",
    "            = \\frac{1}{2} \\ket{00} - \\frac{1}{2} \\ket{01} + \\frac{1}{2} \\ket{10} - \\frac{1}{2} \\ket{11} \n",
    "            = \\myrvector{ \\frac{1}{2} \\\\ - \\frac{1}{2} \\\\ \\frac{1}{2} \\\\ - \\frac{1}{2} }.\n",
    "        $$\n",
    "</ul>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<h4> Case 3: Let's find $ H^{\\otimes 2} \\ket{10} $ (in three different ways) </h4>\n",
    "<ul>\n",
    "    <li> Direct matrix-vector multiplication:\n",
    "        $$\n",
    "            H^{\\otimes 2} \\ket{10} \n",
    "            = \\Htwo \\myvector{0 \\\\ 0 \\\\ 1 \\\\ 0} \n",
    "            = \\myrvector{ \\frac{1}{2} \\\\ \\frac{1}{2} \\\\ - \\frac{1}{2} \\\\ - \\frac{1}{2} } .\n",
    "        $$ </li> \n",
    "    <li> We calculate the quantum state of each state, and then find the quantum state of the composite system.\n",
    "        $$\n",
    "            H\\ket{1} \\otimes H \\ket{0} \n",
    "            = \\vhadamardone \\otimes \\vhadamardzero \n",
    "            = \\myrvector{ \\frac{1}{2} \\\\ \\frac{1}{2} \\\\ - \\frac{1}{2} \\\\ - \\frac{1}{2} }.\n",
    "        $$ </li>\n",
    "    <li> We make calculations with $ \\ket{0} $ and $ \\ket{1} $.\n",
    "        $$\n",
    "            H \\ket{1} \\otimes H \\ket{0} \n",
    "            = \\mypar{ \\frac{1}{\\sqrt{2}} \\ket{0} - \\frac{1}{\\sqrt{2}} \\ket{1} } \n",
    "                \\otimes \\mypar{ \\frac{1}{\\sqrt{2}} \\ket{0} + \\frac{1}{\\sqrt{2}} \\ket{1} }\n",
    "            = \\frac{1}{2} \\ket{00} + \\frac{1}{2} \\ket{01} - \\frac{1}{2} \\ket{10} - \\frac{1}{2} \\ket{11} \n",
    "            = \\myrvector{ \\frac{1}{2} \\\\ \\frac{1}{2} \\\\ - \\frac{1}{2} \\\\ -\\frac{1}{2} }.\n",
    "        $$\n",
    "</ul>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<h4> Case 4: Let's find $ H^{\\otimes 2} \\ket{11} $ (in three different ways) </h4>\n",
    "<ul>\n",
    "    <li> Direct matrix-vector multiplication:\n",
    "        $$\n",
    "            H^{\\otimes 2} \\ket{00} \n",
    "            = \\Htwo \\myvector{0 \\\\ 0 \\\\ 0 \\\\ 1} \n",
    "            = \\myrvector{ \\frac{1}{2} \\\\ - \\frac{1}{2} \\\\ - \\frac{1}{2} \\\\ \\frac{1}{2} } .\n",
    "        $$ </li> \n",
    "    <li> We calculate the quantum state of each state, and then find the quantum state of the composite system.\n",
    "        $$\n",
    "            H\\ket{1} \\otimes H \\ket{1} \n",
    "            = \\vhadamardone \\otimes \\vhadamardone \n",
    "            = \\myrvector{ \\frac{1}{2} \\\\ - \\frac{1}{2} \\\\ - \\frac{1}{2} \\\\ \\frac{1}{2} }.\n",
    "        $$ </li>\n",
    "    <li> We make calculations with $ \\ket{0} $ and $ \\ket{1} $.\n",
    "        $$\n",
    "            H \\ket{1} \\otimes H \\ket{1} \n",
    "            = \\mypar{ \\frac{1}{\\sqrt{2}} \\ket{0} - \\frac{1}{\\sqrt{2}} \\ket{1} } \n",
    "                \\otimes \\mypar{ \\frac{1}{\\sqrt{2}} \\ket{0} - \\frac{1}{\\sqrt{2}} \\ket{1} }\n",
    "            = \\frac{1}{2} \\ket{00} - \\frac{1}{2} \\ket{01} - \\frac{1}{2} \\ket{10} + \\frac{1}{2} \\ket{11} \n",
    "            = \\myrvector{ \\frac{1}{2} \\\\ - \\frac{1}{2} \\\\ - \\frac{1}{2} \\\\ \\frac{1}{2} }.\n",
    "        $$\n",
    "</ul>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<hr>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<h3> CNOT operator </h3>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "CNOT is an operator defined on two qubits:\n",
    "\n",
    "$$\n",
    "    CNOT = \\mymatrix{cccc}{1 & 0 & 0 & 0 \\\\ 0 & 1 & 0 & 0 \\\\ 0 & 0 & 0 & 1 \\\\ 0 & 0 & 1 & 0} .\n",
    "$$\n",
    "\n",
    "Its effect is very simple: if the state of the first qubit is one, then the state of the second qubit is flipped. \n",
    "\n",
    "If the state of the first bit is zero, then the state of the second qubit remains the same. \n",
    "\n",
    "In summary:\n",
    "<ul>\n",
    "    <li>$ CNOT \\ket{00} = \\ket{00} $, </li>\n",
    "    <li>$ CNOT \\ket{01} = \\ket{01} $, </li>\n",
    "    <li>$ CNOT \\ket{10} = \\ket{11} $, and, </li>\n",
    "    <li>$ CNOT \\ket{11} = \\ket{10} $. </li>\n",
    "</ul>\n",
    "\n",
    "CNOT refers to Controlled-NOT: NOT operator is applied in a controlled way."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<h3> cx-gate </h3>\n",
    "\n",
    "In Qiskit, CNOT operator is represented as cx-gate.\n",
    "\n",
    "It takes two arguments: controller-qubit and target-qubit.\n",
    "\n",
    "Its implementation is as follows:\n",
    "\n",
    "<i> <b>x-gate</b> (NOT operator) is applied to <u>the target qubit</u> that is <b>CONTROLLED</b> by <u>the controller qubit</u>.</i> \n",
    "\n",
    "Let's apply CNOT to the states $ \\ket{00}, \\ket{01}, \\ket{10}, \\ket{11} $ in python."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# import all necessary objects and methods for quantum circuits\n",
    "from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, Aer\n",
    "from qiskit.tools.visualization import matplotlib_circuit_drawer as drawer\n",
    "\n",
    "# we use four pairs of two qubits in order to see all results at once\n",
    "# the first pair -> qubits with indices 0 and 1\n",
    "# the second pair -> qubits with indices 2 and 3\n",
    "# the third pair -> qubits with indices 4 and 5\n",
    "# the fourth pair -> qubits with indices 6 and 7\n",
    "qreg =  QuantumRegister(8)\n",
    "creg = ClassicalRegister(8)\n",
    "mycircuit = QuantumCircuit(qreg,creg)\n",
    "\n",
    "# the first pair is already in |00>\n",
    "\n",
    "# the second pair is set to be in |01>\n",
    "mycircuit.x(qreg[3])\n",
    "\n",
    "# the third pair is set to be in |10>\n",
    "mycircuit.x(qreg[4])\n",
    "\n",
    "# the fourth pair is set to be in |11>\n",
    "mycircuit.x(qreg[6])\n",
    "mycircuit.x(qreg[7])\n",
    "\n",
    "# apply cx to each pair\n",
    "for i in range(0,8,2): # i = 0,2,4,6\n",
    "    mycircuit.cx(qreg[i],qreg[i+1])\n",
    "\n",
    "# measure the quantum register\n",
    "mycircuit.measure(qreg,creg)\n",
    "\n",
    "print(\"Everything looks fine, let's continue ...\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "# draw the circuit\n",
    "\n",
    "drawer(mycircuit)\n",
    "# re-run this cell if you DO NOT see the circuit diagram"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# execute the circuit 1000 times in the local simulator\n",
    "\n",
    "job = execute(mycircuit,Aer.get_backend('qasm_simulator'),shots=1000)\n",
    "counts = job.result().get_counts(mycircuit)\n",
    "# print the reverse of the output\n",
    "for outcome in counts:\n",
    "    reverse_outcome = ''\n",
    "    for i in outcome:\n",
    "        reverse_outcome = i + reverse_outcome\n",
    "    print(reverse_outcome,\"is observed\",counts[outcome],\"times\")\n",
    "    print()\n",
    "    print(\"let's also split into the pairs\")\n",
    "    for i in range(0,8,2):\n",
    "        print(reverse_outcome[i:i+2])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<h3> Task 1 </h3>\n",
    "\n",
    "Create a quantum curcuit with $ n=5 $ qubits.\n",
    "\n",
    "Set each qubit to $ \\ket{1} $.\n",
    "\n",
    "Repeat 4 times:\n",
    "<ul>\n",
    "    <li>Randomly pick a pair of qubits, and apply cx-gate (CNOT operator) on the pair.</li>\n",
    "</ul>\n",
    "\n",
    "Draw your circuit, and execute your program 100 times.\n",
    "\n",
    "Verify your measurement results by checking the diagram of the circuit. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# import all necessary objects and methods for quantum circuits\n",
    "from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, Aer\n",
    "from qiskit.tools.visualization import matplotlib_circuit_drawer as drawer\n",
    "# import randrange for random choices\n",
    "from random import randrange\n",
    "\n",
    "#\n",
    "# your code is here\n",
    "#\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a href=\"..\\bronze-solutions\\B56_Two_Qubits_Solutions.ipynb#task1\">click for our solution</a>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<h3>Task 2</h3>\n",
    "\n",
    "Our task is to learn the behaviour of the following quantum circut by doing experiments.\n",
    "\n",
    "Our circuit has two qubits. \n",
    "<ul>\n",
    "    <li> Apply Hadamard to the both qubits.\n",
    "    <li> Apply CNOT(first-qubit,second-qubit).\n",
    "    <li> Apply Hadamard to the both qubits.\n",
    "    <li> Measure the circuit.\n",
    "</ul>\n",
    "\n",
    "Iteratively initialize  the qubits to $ \\ket{00} $, $ \\ket{01} $, $ \\ket{10} $, and $ \\ket{11} $.\n",
    "\n",
    "Execute your program 100 times for each iteration, and then check the outcomes for each iteration. \n",
    "\n",
    "Verify that the overall circuit implements CNOT(second-qubit,first-qubit)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# import all necessary objects and methods for quantum circuits\n",
    "from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, Aer\n",
    "from qiskit.tools.visualization import matplotlib_circuit_drawer as drawer\n",
    "\n",
    "#\n",
    "# your code is here\n",
    "#\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a href=\"..\\bronze-solutions\\B56_Two_Qubits_Solutions.ipynb#task2\">click for our solution</a>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<h3>Task 3</h3>\n",
    "\n",
    "Our task is to learn the behaviour of the following quantum circut by doing experiments.\n",
    "\n",
    "Our circuit has two qubits. \n",
    "<ul>\n",
    "    <li> Apply CNOT(first-qubit,second-qubit).\n",
    "    <li> Apply CNOT(second-qubit,first-qubit).\n",
    "    <li> Apply CNOT(first-qubit,second-qubit).\n",
    "</ul>\n",
    "\n",
    "Iteratively initialize  the qubits to $ \\ket{00} $, $ \\ket{01} $, $ \\ket{10} $, and $ \\ket{11} $.\n",
    "\n",
    "Execute your program 100 times for each iteration, and then check the outcomes for each iteration. \n",
    "\n",
    "Verify that the overall circuit swaps the values of the first and second qubits:\n",
    "<ul>\n",
    "    <li> $\\ket{00} \\rightarrow \\ket{00} $ </li>\n",
    "    <li> $\\ket{01} \\rightarrow \\ket{10} $ </li>\n",
    "    <li> $\\ket{10} \\rightarrow \\ket{01} $ </li>\n",
    "    <li> $\\ket{11} \\rightarrow \\ket{11} $ </li>\n",
    "</ul>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# import all necessary objects and methods for quantum circuits\n",
    "from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, Aer\n",
    "from qiskit.tools.visualization import matplotlib_circuit_drawer as drawer\n",
    "\n",
    "#\n",
    "# your code is here\n",
    "#\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a href=\"..\\bronze-solutions\\B56_Two_Qubits_Solutions.ipynb#task3\">click for our solution</a>"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
